import BNodeAction from "../base/BNodeAction";
import {ActionResult} from "../BTreeActionResult";

const {ccclass, property} = cc._decorator;
/**
 <tree-start>
 {
	"path": "actions",
	"color": "lightblue",
	"parameter": {
		"text": ""
	},
	"tip": "log"
}
 <tree-end>
 */
@ccclass
export default class BNodeLog extends BNodeAction {
    private text: string = null;
    private logError: boolean = false;

    protected onEnter(): void {
        this.text = this.parameter["text"];
        this.logError = this.parameter["logError"];
    }

    protected onExcute(): ActionResult {
        if (this.logError) {
            cc.error(this.text);
        } else {
            cc.log(this.text);
        }
        return ActionResult.SUCCESS;
    }
}
